<?php
require __DIR__ . '/../../vendor/autoload.php';

$queue = new \SuperTool\FileQueue([
	// 数据库名称
	'databaseRoot' => './file-queue/test'
]);

// 模拟10个消费者进程 
foreach (range(1, 10) as $task) {
    $pool[] = proc_open("php test_push.php", [], $pipe);
    $pool[] = proc_open("php test_pop.php", [], $pipe);
}

// 回收子进程
while (count($pool)) {
    foreach ($pool as $i => $result) {
        $etat = proc_get_status($result);
        if($etat['running'] == FALSE) {
            proc_close($result);
            unset($pool[$i]);
        }
    }
}